<template>
	<view class="grid-wap">
<!-- 		<view class="mybtn">
			<view class="con">
				我的服务
			</view>
		</view> -->
	<view class=" u-flex u-flex-wrap u-col-center" v-if="list.length">
		<view class="grid-item u-flex-col u-row-center u-col-center" v-for="(menu, index) in list" :key="index"
			@tap="jump(menu)">
			<image class="tool-img" :src="menu.image" mode="aspectFill"></image>
			<view class="item-title">{{ menu.name }}</view>
		</view>
		<ljshop-share v-model="showShare" posterType="user"></ljshop-share>
	</view>
	</view>
</template>

<script>
	/**
	 * shGrid-宫格列表
	 * @property {Array} list  - 宫格列表
	 */
	import {
		mapMutations,
		mapActions,
		mapState,
		mapGetters
	} from 'vuex';
	import wechat from '@/ljshop/wechat/wechat';
	export default {
		components: {},
		data() {
			return {
				showShare: false,
			};
		},
		computed: {},
		props: {
			list: {
				type: Array,
				default: () => {
					return [];
				}
			}
		},
		created() {},
		methods: {
			// 点击分享

			jump(data) {
				if (data.path.indexOf("invite") != -1) {
					if(uni.getStorageSync("UId") > 0){
						this.onShare();
					}else{
						// #ifdef APP-PLUS
						uni.navigateTo({
							url: "/subunimodules/uni-id-pages/pages/login/login-withoutpwd?type=" + this.loginType
						})
						// #endif
						// #ifdef MP-WEIXIN
						uni.showToast({
							title: '请登录后操作',
							icon: 'none'
						});
						// #endif
					}
					
					
				}
				else if (data.path.indexOf("scan") != -1) {
					uni.scanCode({
						scanType: ['qrCode'],
						success: function(res) {
							console.log('条码类型：' + res.scanType);
							console.log('条码内容：' + res.result);
							if(res.result.indexOf("room_") != -1){
								uni.navigateTo({
									url:  "/pages/live/live?id=" + res.result.split("_")[1],
								});
							}
						}
					});
				} else {
					if(data.path_type==2){//需要登录
				 
						if(uni.getStorageSync("UId")>0){
							
							if(data.path.indexOf("/tuandui/list")!=-1){
								let that = this;
								that.loadStatus = 'loadmore';
								that.$http('user.apiinfo', {
									UId: uni.getStorageSync("UId"),
								}).then(res => {
									if (res) {
										if (res.data.showcc == 1) {
											this.$Router.push({
												path: '/pages/tuandui/list',
											})
										} else {
											this.$Router.push({
												path: '/pages/public/webview',
												query: {
													webviewPath: "https://www.hzwltb69.com/article/detail/152"
												}
											})
										}
									}
								});
							}else{
								this.$tools.routerTo(data.path);
							}
						}else{
							// #ifdef APP-PLUS
							uni.navigateTo({
								url: "/subunimodules/uni-id-pages/pages/login/login-withoutpwd?type=" + this.loginType
							})
							// #endif
							// #ifdef MP-WEIXIN
							uni.showToast({
								title: '请登录后操作',
								icon: 'none'
							});
							// #endif
						}
						
					}else{
						this.$tools.routerTo(data.path);
					}
					
				}
			},
			onShare() {
				this.showShare = true
			},
		}
	};
</script>

<style lang="scss">
	// 宫格
	.grid-wap {
		background: #fff;
		width: 750rpx;
		padding: 30rpx 0 0;
		background: url("https://image.hzwltb69.com/app/images/backorder.png") no-repeat center / 100% 100%;
		width: 720rpx;
		margin-left: 15rpx;
		border-radius: 25rpx;
		z-index: 10;
		margin-top: 12rpx;
		.grid-item {
			width: 20%;
			margin-bottom: 40rpx;
			.tool-img {
				width: 54rpx;
				height: 54rpx;
				border-radius: 100rpx;
			}
			.item-title {
				font-size: 24rpx;
				font-weight: 500;
				color: #000;
				line-height: 24rpx;
				padding-top: 25rpx;
				// font-weight: 600;
			}
		}
		
	}
	.mybtn{
		display: flex;
		align-items: center;
		i{
			width: 1rpx;
			height: 30rpx;
			border-right: 7rpx solid red;
		}
		.con{
			// margin-left: 20rpx;
			font-weight: 600;
		}
		margin-left: 20rpx;
		margin-bottom: 20rpx;
	}
</style>
